package work.timejay.config;

/**
 * @className:MinioConfig.java
 * @author:王文杰
 * @version:1.0.0
 * @description:mino配置文件
 * @createTime 2023年11月23日 17:01:00
 */

import io.minio.MinioClient;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

@Configuration
@ConfigurationProperties(prefix = "minio")
@Slf4j
@Data
public class MinioConfig {

    private String endpoint;

    private String accessKey;

    private String secretKey;

    private String bucketName;


    @Bean()
    @Scope(value = "singleton")
    public MinioClient minioClient() {
        log.info("endpoint,accessKey,secretKey,bucketName--->{},{},{},{}", endpoint, accessKey, secretKey, bucketName);
        return MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build();
    }
}
